import bsinRequest from '../utils/bsinRequest';
let workflowAdminPath = process.env.contextPath_workflowAdmin;
let workflowPath = process.env.contextPath_workflow;


// 获取模板类型树
export const getModelTypeTree = (params: object) => {
  return bsinRequest(workflowAdminPath + '/modelType/getModelTypeTree', {
    serviceName: 'BsinAdminModelTypeService',
    methodName: 'getModelTypeTree',
    bizParams: {
      ...params,
    },
  });
};

// 请求模板列表
export const getPageListModel = (params: object) => {
  return bsinRequest(workflowAdminPath + '/model/getPageListModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'getPageListModel',
    bizParams: {
      ...params,
    },
  });
};

// 保存对应的模板信息
export const saveModel = (params: object) => {
  return bsinRequest(workflowAdminPath + '/model/saveModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'saveModel',
    bizParams: {
      ...params,
    },
  });
};

// 删除对应的模板信息
export const deleteModel = (params: object) => {
  return bsinRequest(workflowAdminPath + '/model/deleteModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'deleteModel',
    bizParams: {
      ...params,
    },
  });
};

// 保存对应的模板xml信息
export const saveModelXML = (params: object) => {
  return bsinRequest(workflowAdminPath + '/model/saveModelXML', {
    serviceName: 'BsinAdminModelService',
    methodName: 'saveModelXML',
    bizParams: {
      ...params,
    },
  });
};

// 部署/发布模型
export const deployModel = (params: object) => {
  return bsinRequest(workflowAdminPath + '/model/deployModel', {
    serviceName: 'BsinAdminModelService',
    methodName: 'deployModel',
    bizParams: {
      ...params,
    },
  });
};

// 获取xml
export const getModelById = (params: object) => {
  return bsinRequest(workflowAdminPath + '/model/getModelById', {
    serviceName: 'BsinAdminModelService',
    methodName: 'getModelById',
    bizParams: {
      ...params,
    },
  });
};

// 获取流程定义
export const getProcessDefinitionPageList = (params: object) => {
  return bsinRequest(workflowAdminPath + '/processDefinition/getProcessDefinitionPageList', {
    serviceName: 'BsinAdminProcessDefinitionService',
    methodName: 'getProcessDefinitionPageList',
    bizParams: {
      ...params,
    },
  });
};

// 获取流程定义
export const getProcessDefinitionStartForm = (params: object) => {
  return bsinRequest(workflowAdminPath + '/formRepository/getProcessDefinitionStartForm', {
    serviceName: 'BsinFormRepositoryService',
    methodName: 'getProcessDefinitionStartForm',
    bizParams: {
      ...params,
    },
  });
};

// 根据流程定义ID启动流程
export const startProcessInstanceById = (params: object) => {
  return bsinRequest(workflowPath + '/runtime/getProcessDefinitionStartForm', {
    serviceName: 'BsinRuntimeService',
    methodName: 'startProcessInstanceById',
    bizParams: {
      ...params,
    },
  });
};

// 根据启动表单启动流程
export const startProcessInstanceWithForm = (params: object) => {
  return bsinRequest(workflowPath + '/runtime/startProcessInstanceWithForm', {
    serviceName: 'BsinRuntimeService',
    methodName: 'startProcessInstanceWithForm',
    bizParams: {
      ...params,
    },
  });
};
